var num:number = 10
var num2:number = 2
var res:number
res = num + num2
console.log(res)
num2++
console.log(num2)
console.log(typeof num)
var string:string = 'san.'+'zhang'
console.log(string)
var age:number = 12
switch(age){
    case 10:
        console.log("这是弟弟");
        break;
    case 12:
        console.log("这是自己")
        break;
    case 14:
        console.log("这是姐姐")
        break;
}
for(var i:number=0;i<5;i++){
    if(i>=5){
        break;
    }else{
        console.log("i的值",i)
    }
}
function fun1(): void{
    console.log("调用fun1函数")
}
fun1()
function fun2():string{
    return 'hello world!'
}
console.log(fun2())
function fun3(x:number,y:number,z:boolean):void{
    if(z){
        console.log("x+y",x+y)
    }else{
        console.log("x-y",x-y)
    }
}
fun3(10,5,true)
//函数的可选参数
function fun4(firstname:string,lastname?:string):string{
 if(lastname){
    return firstname+lastname
 }else{
    return firstname
 }
}
console.log(fun4('张'))
console.log(fun4('李','四'))
//函数的默认参数
function fun5(firstname:string,lastname:string='凌凌'):string{
    return firstname+lastname
}
console.log(fun5('张'))
console.log(fun5('李','琳琳'))
//剩余参数
//将一个不确定数量的参数作为一个数组传入
function add(...arr:number[]):number{
    var nums:number = 0
    for(var i:number=0;i<arr.length;i++){
        nums+=arr[i]
    }
    return nums
}
console.log(add(1,2,3))
console.log(add(10,20,10,10))
//匿名函数
var msg = function(x:boolean,y:string):void{
    console.log(x,y)
}
msg(false,"888")
//构造函数
var myFun = new Function("a","b","return a * b")
var ress = myFun(3,4)
console.log(ress)
//Number
var a = Number(false)
console.log(a)
var b:number = 123.45678
console.log(b.toFixed(3))
//String
var str = new String('cyh')
console.log(str,String('cyh'))
console.log(str.constructor)
console.log(String('cyh').length)
console.log(String.prototype)
console.log('str'.charAt(0))

//多维数组
var multiArr:number[][] = [[1,2,3],[4,5,6]]
console.log(multiArr)
